
// Computes table with Gini coefficient used in the paper

preserve

gen double tax_new_011=cral_sty
gen double tax_new_022=cral_sty
gen double tax_new_033=cral_sty

forvalues shift=0/9{

nois disp in red "`shift'"

capture drop rentaneta
gen rentaneta=gross_income-tax_new_`shift'11	//net income

sum gross_income if nivel==1 [iw=factor]
local i100=r(sum)
sum gross_income [iw=factor]
nois disp in green "Sy " `i100'/r(sum)

sum tax_new_`shift'11 if nivel==1 [iw=factor]
local i100=r(sum)
sum tax_new_`shift'11 [iw=factor]
nois disp in green "St " `i100'/r(sum)

sum rentaneta if nivel==1 [iw=factor]
local i100=r(sum)
sum rentaneta [iw=factor]
nois disp in green "Sy-t " `i100'/r(sum)

sum gross_income if nivel==0 [iw=factor]
local inc=r(sum)
sum tax_new_`shift'11 if nivel==0 [iw=factor]
nois disp in green "t99 " r(sum)/`inc'

sum gross_income if nivel==1 [iw=factor]
local inc=r(sum)
sum tax_new_`shift'11 if nivel==1 [iw=factor]
nois disp in green "t100 " r(sum)/`inc'

sum gross_income[iw=factor]
local inc=r(sum)
sum tax_new_`shift'11 [iw=factor]
nois disp in green "t " r(sum)/`inc'

ginis gross_income [aw=factor] if nivel==0
nois disp "Gy99 " %18.17g $ginis
ginis gross_income [aw=factor] if nivel==1
nois disp "Gy100 " %18.17g $ginis
ginis gross_income [aw=factor]
nois disp "Gy " %18.17g $ginis
	
	foreach var in tax_new_`shift'11 tax_new_`shift'22 tax_new_`shift'33{

	capture drop rentaneta
	gen rentaneta=gross_income-`var'

	ginis `var' [aw=factor] if nivel==0
	nois disp "Gt99 " %18.17g $ginis
	ginis `var' [aw=factor] if nivel==1
	nois disp "Gt100 " %18.17g $ginis
	ginis `var' [aw=factor]
	nois disp "Gt " %18.17g $ginis

	ginis rentaneta [aw=factor] if nivel==0
	nois disp "Gy-t99 " %18.17g $ginis
	ginis rentaneta [aw=factor] if nivel==1
	nois disp "Gy-t100 " %18.17g $ginis
	ginis rentaneta [aw=factor]
	nois disp "Gy-t " %18.17g $ginis
	
	}

}


restore
